#include <stdio.h>

#include "hello.h"

/* The program to test:
* 1 how to use libs and generate libs.
* 2 how to use -l -L -lm to link libs and math libs
* 3 how to call a function with using libs
* 4 The main goal is to figure out to complier and linker.
*/

/* Test steps:
* 1 you can build main.c ,to use the commands "gcc main.c hello.c hello.h -o main.out" ------> ./main.out ------> Get results.
* 2 gcc hello.c ---> will be error,because "main function" is necessary for build a program. But you can use "gcc -c hello.c" to generate "hello.o"
* 3 so you can use "ar -crv libhello.a hello.o" to generate "libhello.a" or "libhello.so".
* 4 you can use 
*   "gcc main.c -I ./include/ -L ./ -lhello -o main.out" 
*   "gcc main.c -I ./include/ -L ./ -l hello -o main.out"
*   "gcc main.c -I ./include/ -L ./ libhello.a -o main.out"
*   "gcc main.c -I ./include -L ./ -l hello -pedantic -Wall -Werror -o main.out" --->add some check error
*   "gcc main.c -shared -I ./include -L ./ -l hello -pedantic -Wall -Werror -o main.out" ---> only use dynamic libs to link
*   "gcc main.c -static -I ./include -L ./ -l hello -pedantic -Wall -Werror -o main.out" ---> only use static libs to link
*   to link libs and include header files.
* 5 The path "/usr/local/lib or /usr/lib"  are default libs path,so you can use '-lname'" to link libs file.
*
*
* Tips: 
* 1 "-I + header file path" to include header file folder,find header files firstly here.
* 2 "-L + libs file path" to link libs file folder,to find libs files firstly here.
* 3 "-l + libs name" to find libs which are static or shared libs.you can also add libs path "./libhello.a" to link libs file.
* 4 "-lm + libs name" to find math libs.Such as: "-lm `pkg-config --cflags --libs opencv `"
*/

/* The program's process:
* 1 preprocessing ---> you can use "gcc -E hello.c -o hello.i" to generate preprocess file.
* 2 compilation   ---> you can use "gcc -S hello.i -o hello.s" to generate assembly file.
* 3 assembly      ---> you can use "gcc -c hello.s -o hello.o" to generate object file.
* 4 linking       ---> you can use "gcc hello.o -o hello.out" to generate executable file.
*
*/

/*Static libs and dynamic libs:
* 1 use static libs to generate static executable and use dynamic libs to generate dynamic executable
* 2 you can use "ldd main.out" to find link all libs,but main.out is dynamic executable.
* 3 (1) 静态链接是指在编译阶段直接把静态库加入到可执行文件中去，这样可执行文件会比较大。
*        链接器将函数的代码从其所在地（不同的目标文件或静态链接库中）拷贝到最终的可执行程序中。为创建可执行文件，链接器必须要完成的主要任务是：符号解析（把目标文件中符号的定义和引用联系起来）和重定位（把符号定义和内存地址对应起来然后修改所有对符号的引用）。
*   (2) 动态链接则是指链接阶段仅仅只加入一些描述信息，而程序执行时再从系统中把相应动态库加载到内存中去
* 参数解释：-fPIC（Position Independent Code）：这个参数用于编译生成位置无关代码。它主要用于编译动态链接库（shared library），
*       确保代码可以在内存中的任意位置执行。动态链接库可以被多个程序共享，因此需要能够在不同的内存地址加载和执行。
*
*/

/*The last link to generate ELF file:
* you can use "readelf -a main.out " or other commands to view content.
* you can use "objdump -S main.out" to disassembly the executable file.
*/

/*
* -O2 to optimize
*/
int main(int argc,char * argv[])
{
    hello_world("The XR Glass will be increased!");
    return 0;
}